function public_funtion(star) {
    var num_last = star.substr(-1);
    var num = parseInt(star.toString().substring(0, 1));
    var array = [];
    for (var i = 0; i < 5; i++) {
        if (i < num) {
            array.push(1);
        } else {
            array.push(0);
        }
    }
    return array;
}

function http(url, callback) {
    wx.showNavigationBarLoading()
    wx.request({
        url: url,
        data: {},
        header: {
            'content-type': 'json' // 默认值
        },
        success: function(res) {
            console.log(res)
            wx.hideNavigationBarLoading()
            callback(res.data);

        }
    })
}

function coverMoviesInfo(arr){
    var castArray=[];
    for(var i=0;i<arr.length;i++){
        var cast={
            img: arr[i].avatars ? arr[i].avatars.large:"",
            name: arr[i].name
        }
        castArray.push(cast);
    }
    return castArray;
}

//电影详情演员
function coverMoviesArray(arr) {
    var castsJoin=""
    for(var i=0;i<arr.length;i++){
        castsJoin = castsJoin + arr[i].name+"/";
    }
    return castsJoin.substring(0,castsJoin.length-2);
}

module.exports = {
    public_funtion: public_funtion,
    http: http,
    coverMoviesArray: coverMoviesArray,
    coverMoviesInfo: coverMoviesInfo
}